var arr = [1, 23, 4, 5, 7, 0, 99, -1];

function quick(arr) {
  if (arr.length <= 1) return arr;

  var left = [];
  var right = [];

  // pivot
  var pivotIndex = ~~(arr.length / 2);
  var pivot = arr.splice(pivotIndex, 1)[0];

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] < pivot) left.push(arr[i]);
    if (arr[i] >= pivot) right.push(arr[i]);
  }

  return quick(left).concat(pivot, quick(right));
}

function myquick(arr) {
  var left = []
  var right  = []
  if(arr.length<=1)return arr

  var pivotIndex = ~~(arr.length/2)
  var pivot = arr.splice(pivotIndex,1)[0]

  for(let i = 0;i <arr.length ;i++)
  {
      if(arr[i]< pivot )left.push(arr[i])
      if(arr[i]>= pivot )right.push(arr[i])
  }

  return myquick(left).concat(pivot,myquick(right))
  
}
console.log(myquick(arr));

// 二分查找

//扁平化 查找
var arr = [
  [1, 2, 8, 9],
  [2, 4, 9, 12],
  [4, 7, 10, 13],
  [6, 8, 11, 15],
];
var newarr = [].concat(...arr);
var tag = newarr.some((item) => item === 7);
console.log(tag);
